<?php
/**
* @file bbc_script_adm.php
* Admin Systemblock BBC_SCRIPT
*
* @author PortaMx - Portal Management Extension
* @author Copyright 2008-2011 by PortaMx - http://portamx.com
* @Version: 1.0 RC4
* @Date: 23.02.2011
*/

if(!defined('PortaMx'))
	die('This file can\'t be run without PortaMx');

global $context, $txt;

/**
* @class pmxc_bbc_script_adm
* Admin Systemblock BBC_SCRIPT
* @see bbc_script_adm.php
* @author Copyright by PortaMx - http://portamx.com
*/
class pmxc_bbc_script_adm extends PortaMxC_SystemAdminBlock
{
	/**
	* AdmBlock_content().
	* Open a the richtext editor, to create or edit the content.
	* Returns the AdmBlock_settings
	*/
	function pmxc_AdmBlock_content()
	{
		global $context, $txt;

		// show the content area
		echo '
					<td valign="top" colspan="2" style="padding:4px;">
						<div class="cat_bar catbg_grid">
							<h4 class="catbg catbg_grid"><span class="cat_left_title">'. $txt['pmx_edit_content'] .'</span></h4>
						</div>
						<input type="hidden" id="smileyset" value="PortaMx" />
						<div id="bbcBox_message"></div>
						<div id="smileyBox_message"></div>
						<div>', template_control_richedit($context['pmx']['editorID'], 'smileyBox_message', 'bbcBox_message'), '</div>';

		// If the WYSIWYG editor available and active on save, we need a special handling.
		// The doSubmit() copied the html back to the textarea and we send a html_to_bbc.
		// On this, the Post handler convert the html back to bbc code.
		echo '
						<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
							function PmX_RichEdit_Submit()
							{
								if(oEditorHandle_'. $context['pmx']['editorID'].'.bRichTextPossible && oEditorHandle_'. $context['pmx']['editorID'].'.bRichTextEnabled)
								{
									oEditorHandle_'. $context['pmx']['editorID'].'.doSubmit();
									document.getElementById("extra_cmd").name = "html_to_bbc";
									document.getElementById("extra_cmd").value = "1";
								}
							}
						// ]]></script>
					</td>
				</tr>
				<tr>';

		// return the default settings
		return $this->pmxc_AdmBlock_settings();
	}
}
?>